﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using WFWS.Core;
using System.Web;
using System.Web.Hosting;
using System.IO;
namespace WFWS.AspNetAdapter
{
    class WFWSRequestHandler: IHttpRequestHandler
    {
		private WFWS.Core.HttpResponse _response;
		private WFWS.Core.HttpRequest  _request;

        #region IHttpRequestHandler Members

        public void Execute(WFWS.Core.HttpRequest request)
        {
			_response = new WFWS.Core.HttpResponse(request);
            var workerRequest = WFWSWorkerRequest.Create(Request, Response);

            WFWSAspNetHost host = (WFWSAspNetHost )
                ApplicationHost.CreateApplicationHost(
                    typeof(WFWSAspNetHost ), "/",
                    new DirectoryInfo("../../../../LP/TestWebsite").FullName);

            host.ProcessRequest(workerRequest);
        }

		public WFWS.Core.HttpResponse Response
		{
			get
			{
				return _response;	
			}
		}
		
		public WFWS.Core.HttpRequest Request
		{
			get
			{
				return _request;
			}
		}
        #endregion
    }
}
